﻿ using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

using System.Data;
using System.Data.SqlClient;
namespace library_manage
{
   public class DBHelPer
    {
       //连接字符串
       private static string library = "Data Source=.;Initial Catalog=library;Integrated Security=True";
       //读出
       public static DataTable Read(string sql)
       {
           SqlConnection cxbook = new SqlConnection(library);
           SqlDataAdapter rbook = new SqlDataAdapter(sql,cxbook);
           DataTable booktable = new DataTable();
           rbook.Fill(booktable);
           return booktable;
       }
       //写入
       public static int Write(string sql)
       {
           SqlConnection xrbook = new SqlConnection(library);
           xrbook.Open();
           SqlCommand wrbook = new SqlCommand(sql,xrbook);
           int zxxr = wrbook.ExecuteNonQuery();
           xrbook.Close();
           return zxxr; 
       }
    }
}
